package com.ccys.cms.controller.administrator;

import com.ccys.cms.service.administrator.TblAppVersionWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.administrator.TblAppVersionDTO;
import com.ccys.db.entity.TblAppVersion;
import com.ccys.db.vo.administrator.TblAppVersionWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "系统设置-app version 版本更新")
@RequestMapping("administrator")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) // 开启跨域访问允许
@SuppressWarnings("unchecked")
public class AppVersionWebController {

    @Autowired
    private TblAppVersionWebService tblAppVersionWebService;

    @GetMapping("appVersion")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "osPlatform", value = "1:ios 2:android 3:huawei", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblAppVersionWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblAppVersionDTO dto) {
        return this.tblAppVersionWebService.listObjectsCms(request, response, dto);
    }

    @PutMapping("appVersion")
    @ApiOperation("编辑")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "versioncode", value = "versioncode", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "versionname", value = "versionname", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "message", value = "message", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "url", value = "url", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "appType", value = "appType", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "osPlatform", value = "osPlatform", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "appStatus", value = "appStatus", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblAppVersion entity) {
        return this.tblAppVersionWebService.change(request, response, entity);
    }
}